Imports System.Data.OracleClient


Public Class clsTags

  Public mCmdTags As OracleCommand
  Public mDrTags As OracleDataReader
  Public mIntTagFixxCode As Integer
  Public mStrTagFixxName As String
  Public mStrTagFixxValu As String



  Public Function fnSelectTags() As Boolean

    Dim lStrQuery As String

    If mIntTagFixxCode <> 0 Then
      lStrQuery = "select TAGS_FIXX_CODE,TAGS_FIXX_NAME,TAGS_FIXX_VALU from TRDX_PP_TAGS where "
      lStrQuery = lStrQuery & "TAGS_FIXX_CODE = " & mIntTagFixxCode


      mCmdTags = New OracleCommand(lStrQuery, con)
      mDrTags = mCmdTags.ExecuteReader

      fnSelectTags = True
    Else
      MessageBox.Show("Invalid Values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      fnSelectTags = False
    End If

  End Function




  Public Function fnInsertTags() As Integer

    Dim lIntSeqNum As Integer
    Dim lStrQuery As String


    mCmdTags = New OracleCommand("select count(*) as CNT from TRDX_PP_TAGS", con)
    Dim nCount As Integer = mCmdTags.ExecuteScalar()

    If nCount = 0 Then
      lIntSeqNum = 0
    Else
      mCmdTags = New OracleCommand("select max(TAGS_FIXX_CODE) as CNT from TRDX_PP_TAGS", con)
      lIntSeqNum = mCmdTags.ExecuteScalar
    End If

    lStrQuery = "insert into TRDX_PP_TAGS values(" & (lIntSeqNum + 1) & ",'"
    lStrQuery = lStrQuery & mStrTagFixxName & "','" & mStrTagFixxValu & "')"

    mCmdTags = New OracleCommand(lStrQuery, con)
    mCmdTags.ExecuteNonQuery()

    fnInsertTags = lIntSeqNum + 1

  End Function




  Public Function fnUpdateTags() As Boolean

    Dim lStrQuery As String



    mCmdTags = New OracleCommand("select count(*) as CNT from TRDX_PP_TAGS where TAGS_FIXX_CODE = " _
                                & mIntTagFixxCode, con)
    Dim ncount As Integer = mCmdTags.ExecuteScalar
    If ncount <> 0 Then
      lStrQuery = "update TRDX_PP_TAGS set TAGS_COD_NAME = '" & mStrTagFixxName & "',"
      lStrQuery = lStrQuery & "TAGS_CODE_VALU = '" & mStrTagFixxValu & "'"
      lStrQuery = lStrQuery & " where TAGS_FIXX_CODE = " & mIntTagFixxCode

      mCmdTags = New OracleCommand(lStrQuery, con)
      mCmdTags.ExecuteNonQuery()

      fnUpdateTags = True
    Else
      MessageBox.Show("Invalid values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      fnUpdateTags = False
    End If

  End Function




  Public Function fnSelectAllTags() As Boolean

    Dim lStrQuery As String = ""



    lStrQuery = lStrQuery & "SELECT TAGS_FIXX_CODE,TAGS_FIXX_NAME,TAGS_FIXX_VALU FROM TRDX_PP_TAGS"
    lStrQuery = lStrQuery & " ORDER BY TAGS_FIXX_VALU"

    mCmdTags = New OracleCommand(lStrQuery, con)
    mDrTags = mCmdTags.ExecuteReader

    fnSelectAllTags = True

  End Function

  Public Function fnSelectAllTables() As Boolean

    Dim lStrQuery As String = ""

    lStrQuery = lStrQuery & "SELECT TABM_TABLE_ID,TABM_TABLE_NAME,TABM_CLNT_SRVR_INDC,TABM_TABLE_SHORT_NAME FROM TRDX_TABLES_MSTR ORDER BY TABM_TABLE_NAME"

    mCmdTags = New OracleCommand(lStrQuery, con)
    mDrTags = mCmdTags.ExecuteReader

    fnSelectAllTables = True

  End Function


End Class
